{% extends "./base.html" %}
{% block title %}Search{% endblock %}
{% block content %}

<div id="search" class="row">
    <div class="span7">
    	{% if user %}
        <a class="btn btn-primary" href="{{ uri.absPath('users', user.key().id(), 'items', 'new').addParams(action='edit') }}">Create an Item</a>
      {% endif %}
    </div>
    <div class="span4">
	<form class="form-search" id="search" action="" method="get">
		<label for="search_terms">Search:</label> <input class="span2" type="text" name="search_terms" value="{{ search_terms }}" />
		<input class="btn btn-primary" type="submit" />
	</form>
    </div>
</div>

<table class="table">
	{% for item in items %}
	<tr>
		<td>
		<a href="{{ uri.absPath('users', item.seller_obj.key().id(), 'items', item.key().id(), returnto=True ) }}">{{ item.title }}</a>
		by <a href="{{ uri.absPath('users', item.seller_obj.key().id()) }}">{{ item.seller_obj.getName() }}</a>

	</td>
	<td>{{item.pretty_desc()}}</td>
	<td><a class="btn btn-info" href="{{ uri.absPath('messages').addParams(recipient=item.seller_obj.key().id()) }}">{{ item.pretty_price() }}</a></td>
	{% endfor %}
</table>
<span>
{% if prev or next %}
	{% for p in prev %}
		<a href="{{ uri.addParams(cursor=p) }}">{{ p }}</a>
	{% endfor %}
	{{ cursor }}
	{% for n in next %}
		<a href="{{ uri.addParams(cursor=n) }}">{{ n }}</a>
	{% endfor %}
{% endif %}
</span>
{% endblock %}
